import { nanoid } from 'nanoid'

export declare type ComponentV2rayServerWebsocketSetting = {
    path: string
    headers_json_string: string
}

export declare type ComponentV2rayServer = {
    uuid: string
    tag: string
    address: string
    port: number
    user_id: string
    alter_id: number
    level: number
    security: string
    network: string
    websocket_setting: ComponentV2rayServerWebsocketSetting
    used: boolean
}

export function new_component_v2ray_server(): ComponentV2rayServer {
    return {
        uuid: nanoid(),
        tag: '',
        address: '',
        port: 443,
        user_id: '',
        alter_id: 0,
        level: 0,
        security: 'none',
        network: 'WebSocket',
        websocket_setting: {
            path: '/',
            headers_json_string: '{"Host": ""}',
        },
        used: false,
    }
}
